<?php

namespace App\Http\Resources\Api;

use App\Models\Enum\UserEnum;
use Illuminate\Http\Resources\Json\JsonResource;

class UserResource extends JsonResource
{
  /**
   * Transform the resource into an array.
   *
   * @param  \Illuminate\Http\Request  $request
   * @return array
   */
  public function toArray($request)
  {
    return [
      'id' => $this->id,
      'nickname' => $this->nickname,
      'avatar' => $this->avatar,
      'birthday' => $this->birthday,
      'gender' => $this->gender,
      'mobile' => $this->mobile,
      'money' => $this->money,
      'score' => $this->score,
      'status' => $this->status,
      'statusMsg' => UserEnum::getStatusName($this->status),
      'wxopenid' => $this->wxopenid,
      'group_id' => $this->group_id,
      'expired' => $this->expired,
      'expired_days' => UserEnum::getExpiredDays($this->expired),
      'qrcode' => $this->qrcode,
      'created_at' => (string)$this->created_at,
      'updated_at' => (string)$this->updated_at
    ];
  }
}
